package com.joven.shelltest.test;

import com.joven.shelltest.utils.IdCardUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.regex.Pattern;

/**
 * 手机号码简单验证
 *
 * @Author wzj
 * @Date 2023-11-17 14:10
 **/
public class OtherTest14 {
    public static void main(String[] args) {
//        int availableCores = Runtime.getRuntime().availableProcessors();
//        System.out.println(availableCores);
//        int numberOfThreads = Math.max(availableCores - 1, 1);
//        System.out.println(numberOfThreads);

//        System.out.println(verifyPhone("11157809377"));

        System.out.println(IdCardUtils.verifyIdCard("330822199511260031"));

        int[] arr = {64, 34, 25, 12, 22, 11, 90};
        bubbleSort(arr);
        System.out.println("排序后的数组：");
        for (int num : arr) {
            System.out.print(num + " ");
        }
    }

    public static boolean verifyPhone(String phone) {
        String regex = "^[1]([3-9])[0-9]{9}$";
        boolean isMatch = false;
        if (StringUtils.isEmpty(phone)) {
            System.out.println("手机号不能为空");
        } else if (phone.length() != 11) {
            System.out.println("手机号应为11位数");
        } else {
            isMatch = Pattern.matches(regex, phone);
        }
        return isMatch;
    }

    public static void bubbleSort(int[] arr) {
        int n = arr.length;
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    // 交换arr[j]和arr[j + 1]
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }

}
